<template>
  <div class="m-panel">
    <div v-if="title" class="m-panel-title">
      <span class="name">{{ title }}</span>
    </div>
    <span v-else class="m-title-space"></span>
    <slot></slot>
  </div>
</template>
<script>
import { toRefs, defineComponent } from 'vue'
export default defineComponent({
  name: 'MPanel',
  props: {
    title: {
      type: String,
    },
  },
  setup (props) {
    const { title } = toRefs(props)
    return {
      title
    }
  }
})
</script>
<style lang="less" scoped>
.m-panel {
  background-color: #f5f5f5;
  &-title {
    padding: 8px 16px;
    span.name {
      font-size: smaller;
      color: #999;
    }
  }
  .m-title-space {
    display: list-item;
    width: 100%;
    height: 10px;
  }
}
</style>
